package com.stt.design.composite;

import com.stt.base.model.Device;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;

/**
 * 设备组
 * 组合模式：管理设备集合，支持批量操作
 */
@Getter
public class DeviceGroup {
    private String name;
    private List<Device> devices = new ArrayList<>();
    
    public DeviceGroup(String name) {
        this.name = name;
    }
    
    /**
     * 添加设备到组
     */
    public void addDevice(Device device) {
        devices.add(device);
    }
    
    /**
     * 从组中移除设备
     */
    public void removeDevice(Device device) {
        devices.remove(device);
    }
    
    /**
     * 设置组内所有设备状态
     */
    public void setAllDevicesStatus(boolean status) {
        devices.forEach(device -> device.setStatus(status));
    }
    
    /**
     * 设置组内所有设备参数
     */
    public void setAllDevicesParameter(Integer parameter) {
        devices.forEach(device -> device.setParameter(parameter));
    }
} 